<?php
require_once '../lib/controller.php';

class action extends controller
{
	function do_get()
	{
		$db = $this->module('lib.db');
		$context = $this->get_context( array('db'=>$db) );
		$site = $this->module('biz.cate', $context);
		$site->delete_cate( array('id'=>$this->get['id']) );

		$this->msg('删除成功', 3, 'cate_list.php');
	}

	function check_privileges()
	{
		if( ! isset($this->session['user_id']) )
		{
			$this->msg('请先登录', 3, 'login.php');
			return false;
		}
		else if( $this->session['user_id'] != 1 )
		{
			$this->msg('只有管理员才能操作', 0, 'cate_list.php');
			return false;
		}
		else
		{
			return true;
		}
	}

	public function check_get()
	{
		if( ! is_numeric($this->get['id']) || ! preg_match("/[0-9]{1,}/", $this->get['id']) )
		{
			$this->msg('参数错误');
			return false;
		}
		return true;
	}
}

$action = new action();
$action->run();
?>